package com.taiyuan.tongcheng.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.taiyuan.tongcheng.bean.ServerStation;
import com.tytc56.user.R;

public class OderStationAdapter extends BaseAdapter {
	private LayoutInflater layoutInflater;
	private Context context;
	private List<ServerStation> stationList=new ArrayList<ServerStation>();

	public OderStationAdapter(Context context, List<ServerStation> stationList) {
		this.context = context;
		this.layoutInflater = LayoutInflater.from(context);
		this.stationList=stationList;
	}

	public int getCount() {
		return stationList.size();
	}

	public Object getItem(int position) {
		return stationList.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ZuJian zuJian = null;
		if (convertView == null) {
			zuJian = new ZuJian();
			convertView = layoutInflater.inflate(R.layout.listview_oder_station,
					null);
			zuJian.staImg=(ImageView)convertView.findViewById(R.id.img_order_sta);
			zuJian.staAddress=(TextView)convertView.findViewById(R.id.tv_order_sta);
			convertView.setTag(zuJian);
		} else {
			zuJian = (ZuJian) convertView.getTag();
		}
		zuJian.staImg.setImageResource(stationList.get(position).getId());
		zuJian.staAddress.setText(stationList.get(position).getPlace());
		return convertView;
	}

	public final class ZuJian {
		public ImageView staImg;
		public TextView staAddress;
	}

}